Repository navigation
Bundle tokeniser, fix Claude 5 token counts, drop Ollama - #65
Merged
Merged
Conversation
Token counts were roughly 30% low for Claude Opus 5, Sonnet 5 and Fable 5. Those models use the tokeniser introduced with Opus 4.7, which produces about 30% more tokens than earlier Claude models for the same text. The offline correction factor was calibrated against the old tokeniser, and the count_tokens API calls were pinned to claude-sonnet-4-5. - Add -m/--model (default claude-opus-5), driving both the offline correction factor and the model sent to count_tokens - Scale offline counts by 1.53 for Opus 4.7 and later, 1.18 for earlier Claude models, and leave non-Claude models uncorrected - Embed gzipped o200k_base and cl100k_base vocabularies with a custom BpeLoader, so there is no first-run download and no cache directory - Drop p50k/r50k, which have no use for a Claude focused tool - Remove Ollama config and quantest VRAM estimation, dropping ollama, gollama, gopsutil and wmi from the module graph - Wire llm_prompt_prefix and llm_prompt_suffix into LLMConfig, they were documented but orphaned in the removed Ollama struct - Add token package tests and bump dependencies, including glamour v1.0.0
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Token counts were roughly 30% low for Claude Opus 5, Sonnet 5 and Fable 5. Those models use the tokeniser introduced with Opus 4.7, which produces about 30% more tokens than earlier Claude models for the same text. The offline correction factor was calibrated against the old tokeniser, and
count_tokensAPI calls were pinned toclaude-sonnet-4-5.Same input, three ways:
Changes
-m/--model(defaultclaude-opus-5) drives both the offline correction factor and the model sent tocount_tokenso200k_baseandcl100k_baseare embedded gzipped with a customBpeLoader: no first-run download, no cache directory, works offline. Binary 19 MB to 22 MBollama,gollama,gopsutilandwmifrom the module graphllm_prompt_prefixandllm_prompt_suffixnow work, they were documented but orphaned in the removed Ollama structBreaking
-m/--modelnow means the token counting model, not the VRAM estimation model--vram,--quant,--quanttype,--context,--kvcache,--memoryand--fitsare gone--encodingacceptso200kandcl100konly,p50k/r50kremovedllm_modelhas no default,--llmnow errors if it is unset in the configNote
The 1.53 factor is derived rather than measured: the existing 1.18 calibration times Anthropic's documented ~30% increase. Actual error varies with content.
--anthropicstill gives exact counts.